#include "duck.h"

#include <iostream>


Duck::Duck(FlyBehavior *pB)
    : m_FlyBehavior(pB)
{
}

Duck::~Duck()
{
    if (m_FlyBehavior)
    {
        delete  m_FlyBehavior;
    }
}

void Duck::Swim()
{
    std::cout << __FUNCTION__ << std::endl;
}

void Duck::Display()
{
    std::cout << __FUNCTION__ << std::endl;
    m_FlyBehavior->Fly();
}

void Duck::SetFlyBehavior(FlyBehavior *pB)
{
    if (m_FlyBehavior)
    {
        delete m_FlyBehavior;
    }
    m_FlyBehavior = pB;
}

MallardDuck::MallardDuck(FlyBehavior *pB)
    : Duck(pB)
{
}


void MallardDuck::Display()
{
    std::cout << __FUNCTION__ << ':' ;
    m_FlyBehavior->Fly();
}

RedheadDuck::RedheadDuck(FlyBehavior *pB)
    : Duck(pB)
{
}

void RedheadDuck::Display()
{
    std::cout << __FUNCTION__ << ':' ;
    m_FlyBehavior->Fly();
}

RubberDuck::RubberDuck(FlyBehavior *pB)
    : Duck(pB)
{
}

void RubberDuck::Display()
{
    std::cout << __FUNCTION__ << ':' ;
    m_FlyBehavior->Fly();
}
